import request from '@/utils/request'
import { makeFormData } from '@/utils/util'

const api = {
  export: 'eapi/exports/word_export',
  psychologicalBehavior: 'eapi/operator/detail', // 心理行为评测
  childrenHealthPageByChildrenId: 'web/children_health/page', // 儿保详情列表
  childrenHealthDetail: 'web/children_health/detail', // 儿保
  childrenHealthAdd: 'web/children_health/add', // 儿保新增
  childrenHealthModify: 'web/children_health/modify', // 儿保修改
  growEvaluatescale: 'web/children_health/grow_evaluate_scale' // 儿保获取发育评价
}

export function psychologicalBehavior (data = {}) {
  return request({
    url: api.psychologicalBehavior,
    method: 'post',
    data: makeFormData(data)
  })
}

export function getChildrenHealthPageByChildrenId (data = {}) {
  return request({
    url: api.childrenHealthPageByChildrenId,
    method: 'post',
    data: makeFormData(data)
  })
}

export function exportPdf (id = {}) {
  return request({
    url: `${api.export}/${id}`,
    method: 'get'
  })
}

export function getGrowEvaluatescale (params = {}) {
  return request({
    url: api.growEvaluatescale,
    method: 'get',
    params
  })
}

export function getChildrenHealthDetail (data = {}) {
  return request({
    url: api.childrenHealthDetail,
    method: 'post',
    data: makeFormData(data)
  })
}

export function childrenHealthSubmit (data = {}) {
  return request({
    url: api[data.id ? 'childrenHealthModify' : 'childrenHealthAdd'],
    method: 'post',
    data: makeFormData(data)
  })
}
